<?php 
$GLOBALS['Md'] = "Clients";
$GLOBALS['Pd'] = "B";
require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
require_once($_SERVER['DOCUMENT_ROOT']."/Modules/Clientes/modconf.mex");
MYTCONN();
	//================ FORMS ===================
	if (!isset($_POST['SRCID'])) {
		$_POST['SRCID'] = 4;
	}  ?>
<DIV id="src_query" class="Line">
<?php

 $QrTypes = "SELECT REF AS ID, NAME FROM hq_confreports WHERE TYPE = 'SEARCH' AND AREA = 4";
	//=====================Query Form=========================
	form_pr('DepQuery','','','post');
	mn_field('hidden','ED','Trigger','Filters','','','False',''); ?> 
<table width="100%" border="0" cellpadding="1" cellspacing="1" cellspac+ing="1"> 
    <tr bgcolor="#F8F8F8">
      <td>Consulta</td> 
      <td>Critério</td> 
      <td>Valor</td>
      <td>Periodo</td> 
      <td>Usuários</td> 
      <td>Modo</td> 
    </tr>
    <tr bgcolor="#F8F8F8">
      <td><?php
	  mn_field('select','ED','SRCID',$_POST['SRCID'],$QrTypes,'','False','inputbox" 
	  onchange="document.MQuery.action=\''.$MODURL.'src_query.mex\';subform(\'MQuery\',\'Subapp\');');?></td>
      <td><?php $QrCriteria = "SELECT Field AS ID, VALUE AS NAME FROM hq_criteria WHERE REPORT = 1";
	  mn_field('select','ED','SRCCRT','0',$QrCriteria,'','False','inputbox');?></td>
      <td><?php echo mn_field('text','ED','SRCVALUE','','50','30','False','inputbox');?></td>
      <td><?php
	  echo 'De ';
	  mn_field('date','ED','TimeStart',date("Y-m-01"),'MQuery','7','False','inputbox');
      echo ' a ';
	  mn_field('date','ED','TimeEnd',date("Y-m-d"),'MQuery','7','False','inputbox');
	  ?></td>
      <td><?php
	  $QrUsers = "SELECT ref AS ID, name AS NAME FROM systemoffice.main_users WHERE ref_office = {$_SESSION[$SESSOF]}";
	  mn_field('select','ED','CttPhone','',$QrUsers,'Todos','False','inputbox');
	  ?></td>
      <td><?php $QrTypes = "SELECT REF AS ID, NAME FROM hq_confreports WHERE TYPE = 'SCREEN' OR TYPE = 'PRINT'";
	  mn_field('select','ED','SRCTYPE','',$QrTypes,'','False','inputbox');?></td>
    </tr>
    <tr bgcolor="#F8F8F8"> 
      <td colspan="6"><?php mn_field('button','ED','Query','Consultar','','','','" onclick="
	  document.DepQuery.action=\''.$MODURL.'rs_report.mex\';
	  subform(\'DepQuery\',\'DepResults\');'); ?></td>
    </tr> 
</table> 
</form>
<div id="DepResults"></div>